#pragma once

#include "NewBoost.Data.h"

namespace new_boost
{
	class CFeatureExtractor
	{
	public:
		double IFB_TextonSigma;
		int IFB_ImageExtent;
		CImageFilterBank IFB_Prototype;
	public:
		double SPL_HOG_Win_W;
		double SPL_HOG_Win_H;
		double SPL_HOG_Blk_BaseW;
		double SPL_HOG_Blk_BaseH;
		double SPL_HOG_Blk_BaseStrideX;
		double SPL_HOG_Blk_BaseStrideY;
		double SPL_HOG_Blk_ScalingFactor;
		CShapePatternList SPL_HOG;

	public:
		void InitSPL_HOG();
		void InitShapePatternLists();
	public:
		void InitIFB();
	public:
		CImagePositionFeatureExtractor* GetIPFE();
		CImagePyramidPositionFeatureExtractor* GetIPPFE(int CacheSize);
	};

	class CWindowGradient
	{
	public:
		double IFB_TextonSigma;
		int IFB_ImageExtent;
		CImageFilterBank IFB;
		CHistogramConfig* pHistogramConfig;
	public:
		int Hist_BinAmount;
		int FeatureDimension;
	public:
		int CelPix_W;
		int CelPix_H;
		int WinCel_W;
		int WinCel_H;
		CShapePatternList SPL;
	public:
		CImagePyramidPositionFeatureExtractor* pIPPFE;
	public:
		CBicExampleFeatureDataSet RealDataSet;
		//CDataSetForBinaryClassification bcDataSet;
		//CBinaryClassificationExampleList bcExampleList;

	public:
		CWindowGradient();
		~CWindowGradient();
	protected:
		void _InitIFB();
		void _InitSPL();
	public:
		void InitIPPFE(
			double IFB_TextonSigma,
			int IFB_ImageExtent,
			int Hist_BinAmount,
			int CelPix_W,
			int CelPix_H,
			int WinCel_W,
			int WinCel_H
			);
		void InitDataSet(
			CSimpleTypeArray<CBicExampleParentFileNameSet>* pList_BicExampleParentFileNameSet,
			string strFN_BicExampleList, bool fIsTextFileMode);
	public:
		double GetValue(int NodeIndex, int WinCel_X, int WinCel_Y, int BinIndex);
		void MakeGradientVector(double* pDstData, int NodeIndex, double Weight);
		void MakeGradientVector(double* pDstData, const CWeightedClassificationExample& Example);
		void AverageGradient(double* pDstData, const CWeightedClassificationExampleList& ExampleList);
		void AverageGradient(CSimpleTypeArray<double>& DstDataList, const CWeightedClassificationExampleList& ExampleList);
	protected:
		void _DrawCell(
			CImg<int>& imgDst, int Draw_CelPix_W, int Draw_CelPix_H,
			int WinCel_X, int WinCel_Y,
			double ValueRange,
			const double* qSrcCellHistogram);
	public:
		void DrawGradientImage(
			CImg<int>& imgDst, int Draw_CelPix_W, int Draw_CelPix_H,
			const double* qSrcData);
	};
};

